---
layout: blog-default
title: Blog
---
<div class="m-home">
    <div class="main">
        <div class="m-post-list">
            {% for post in paginator.posts %}
                <article>
                    <h1>
                        <a href="{{ post.url | prepend: site.baseurl | replace: '//', '/' }}">{{ post.title }}</a>
                    </h1>
                    <div class="m-article-content">
                        {{ post.excerpt | truncatewords: 200 }}
                    </div>
                    <a href="{{ post.url | prepend: site.baseurl | replace: '//', '/' }}">点击查看更多 ...</a>
                    {% include blog/article-data.html %}
                </article>
            {% endfor %}
        </div>
        {% if paginator.total_pages > 1 %}
            <nav class="m-pagination">
                <p>{{ site.posts | size }} post articles, {{ paginator.total_pages }} pages.</p>
                <ul class="inline-list">
                {% if paginator.previous_page %}
                    <li><a class="round-button" href="{{ paginator.previous_page_path | prepend: site.baseurl | replace: '//', '/' }}">
                        <div class="icon icon--previous">{% include icon/previous.svg %}</div>
                    </a></li>
                {% else %}
                    <li><div class="round-button inactive">
                        <div class="icon icon--prrevious">{% include icon/previous.svg %}</div>
                    </div></li>
                {% endif %}
                {% for page in (1..paginator.total_pages) %}
                    {% if page == paginator.page %}
                        <li><div class="round-button cur">
                            <span>{{ page }}</span>
                        </div></li>
                    {% elsif page == 1 %}
                        <li><a class="round-button"
                            href="{{ '/' | prepend: site.baseurl | replace: '//', '/' }}">
                            <span>{{ page }}</span>
                        </a></li>
                    {% else %}
                        <li><a class="round-button" href="{{ site.paginate_path | prepend: site.baseurl | replace: '//', '/' | replace: ':num', page }}">
                            <span>{{ page }}</span>
                        </a></li>
                    {% endif %}
                {% endfor %}
                {% if paginator.next_page %}
                    <li><a class="round-button" href="{{ paginator.next_page_path | prepend: site.baseurl | replace: '//', '/' }}">
                        <div class="icon icon--next">{% include icon/next.svg %}</div>
                    </a></li>
                {% else %}
                    <li><div class="round-button inactive">
                        <div class="icon icon--next">{% include icon/next.svg %}</div>
                    </div></li>
                {% endif %}
                </ul>
            </nav>
        {% endif %}
    </div>
</div>
{% if site.leancloud.app_id and site.leancloud.app_key and site.leancloud.app_class and site.isdebug == false %}
    <script src="https://cdn1.lncld.net/static/js/av-min-1.2.1.js"></script>
    <script>
        $(function() {
            AV.init({
                appId: '{{ site.leancloud.app_id }}',
                appKey: '{{ site.leancloud.app_key }}'
            });
            $(".article-view").each(function() {
                var curId = this.id;
                var query = new AV.Query('{{ site.leancloud.app_class }}');
                query.equalTo('key', curId.substr(9));
                query.first().then(function(result) {
                    if (result) {
                        $('#' + curId).text(result.attributes.views);
                    }
                }, function(error) {
                    if (error) {
                        throw error;
                    }
                });
            });
        });
    </script>
{% endif %}
